package com.cncsi.web;

import com.cncsi.entity.Department;
import com.cncsi.entity.Project;
import com.cncsi.entity.User;
import com.cncsi.service.DepartmentService;
import com.cncsi.service.ProjectService;
import com.cncsi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * Created by 1N on 2018/9/11.
 */
@Controller
@RequestMapping("/project")
public class ProjectController {

    @Autowired
    private ProjectService projectService;
    @Autowired
    private UserService userService;
    @Autowired
    private DepartmentService departmentService;

    @RequestMapping("/toProject")
    public String getProList(Map<String,Object> map){
        List<Project>  projectList = projectService.getProjectList();
        map.put("projectList",projectList);
        List<User>  userList = userService.getUserList();
        map.put("userList",userList);
        List<Department>  departmentList = departmentService.getDepartmentList();
        map.put("departmentList",departmentList);
        List<Project>  projectAll = projectService.getProjectAll();
        map.put("projectAll",projectAll);
        return "project/project_index";
    }

    @ResponseBody
    @RequestMapping(value = "/saveProject", method = RequestMethod.POST)
    public String saveProject(Project project) {
        System.out.println(project.getProjectName());
        String str = "成功";
        return str;
    }


}
